﻿
using System;
using System.Drawing;

using MonoTouch.Foundation;
using MonoTouch.UIKit;
using Beauty.Module.Pos;
namespace Beauty
{
	public partial class LoginVCtrl : UIViewController
	{
		public LoginVCtrl () : base ("LoginVCtrl", null)
		{
		}

		public override void DidReceiveMemoryWarning ()
		{
			// Releases the view if it doesn't have a superview.
			base.DidReceiveMemoryWarning ();

			// Release any cached data, images, etc that aren't in use.
		}

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			var color = UIColorExtensions.FromHexString("#ff485f");
//	     	txtEmail.Placeholder = "Email Address ...";
//
			txtEmail.KeyboardType = UIKeyboardType.EmailAddress;
			txtEmail.Layer.ZPosition = 1;
			txtEmail.TextColor = color;
			UIView paddingView = new UIView ();
			paddingView.Frame = new RectangleF (20, 0, 40, 50);
			txtEmail.LeftView = paddingView;

			txtEmail.LeftViewMode = UITextFieldViewMode.Always;    

			//txtEmail.Layer.CornerRadius = 15;

			txtPassword.Placeholder = "Password ...";
			txtPassword.KeyboardType = UIKeyboardType.Default;
			txtPassword.SecureTextEntry = true;
			txtPassword.Layer.ZPosition = 1;
			txtPassword.TextColor = color;
//			txtPassword.LeftView = paddingView;
//			txtPassword.LeftViewMode = UITextFieldViewMode.Always;
//			txtPassword.Layer.CornerRadius = 15;
//
//
			btnLogin.BackgroundColor = color;
			btnLogin.Layer.ZPosition = 1;

			UIImageView bg = new UIImageView (PosUtility.ImageFrom("Login_BG"));
			bg.Frame = new RectangleF (0, 0, 1024, 768);
			//View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromFile ("Login_BG.png")).;
			var button = UIButton.FromType (UIButtonType.Custom);
			button.SetTitle ("RadioButton", UIControlState.Normal);
			button.SetTitle ("RadioButton",UIControlState.Highlighted);
			button.SetTitle ("RadioButton",UIControlState.Selected);
			button.SetImage (PosUtility.ImageFrom("Login_ic1"), UIControlState.Normal);
			button.SetImage (PosUtility.ImageFrom ("Login_ic2"), UIControlState.Highlighted);
			button.SetImage (PosUtility.ImageFrom ("Login_ic2"), UIControlState.Selected);

			button.Frame = new RectangleF (80,310, 50, 50);
			button.TouchUpInside += (sender, e) => 
			{
				var uiButton = sender as UIButton;
				uiButton.Selected = !uiButton.Selected;

			};
			lbKeep.Layer.ZPosition = 1;
			lbKeep.Text = "Keep me logged in";
			lbKeep.TextColor = color;    

			lbSignup.Layer.ZPosition = 1;
			lbSignup.Text ="Sign up";
			lbSignup.TextColor = color;

			lbForgot.Layer.ZPosition = 1;
			lbForgot.Text = "Forgot Password ?";
			lbForgot.TextColor = color;


			View.Add (bg);
			View.Add (button);


			var buttonSignup = UIButton.FromType (UIButtonType.Custom);
			buttonSignup.SetTitle ("RadioButton", UIControlState.Normal);
			buttonSignup.SetTitle ("RadioButton",UIControlState.Highlighted);
			buttonSignup.SetTitle ("RadioButton",UIControlState.Selected);
			buttonSignup.SetImage (PosUtility.ImageFrom ("Login_ic1"), UIControlState.Normal);
			buttonSignup.SetImage (PosUtility.ImageFrom ("Login_ic2"), UIControlState.Highlighted);
			buttonSignup.SetImage (PosUtility.ImageFrom ("Login_ic2"), UIControlState.Selected);

			buttonSignup.Frame = new RectangleF (80,400, 50, 50);
			buttonSignup.TouchUpInside += (sender, e) => 
			{
				var uiButton = sender as UIButton;
				uiButton.Selected = !uiButton.Selected;

			};
			View.Add (buttonSignup);

			var buttonForgot = UIButton.FromType (UIButtonType.Custom);
			buttonForgot.SetTitle ("RadioButton", UIControlState.Normal);
			buttonForgot.SetTitle ("RadioButton",UIControlState.Highlighted);
			buttonForgot.SetTitle ("RadioButton",UIControlState.Selected);
			buttonForgot.SetImage (PosUtility.ImageFrom ("Login_ic1"), UIControlState.Normal);
			buttonForgot.SetImage (PosUtility.ImageFrom ("Login_ic2"), UIControlState.Highlighted);
			buttonForgot.SetImage (PosUtility.ImageFrom ("Login_ic2"), UIControlState.Selected);

			buttonForgot.Frame = new RectangleF (80,440, 50, 50);
			buttonForgot.TouchUpInside += (sender, e) => 
			{
				var uiButton = sender as UIButton;
				uiButton.Selected = !uiButton.Selected;

			};
			View.Add (buttonForgot);

			UIImageView img = new UIImageView (PosUtility.ImageFrom("Login_ic_email"));
			img.Frame = new RectangleF (0, 0, 40, 28);
			//ImgEmail.Frame = new RectangleF (0, 0, 15, 15);
			ImgEmail.Layer.ZPosition = 1;
			ImgEmail.Add (img);

			UIImageView imgPass = new UIImageView (PosUtility.ImageFrom ("Login_ic_pw"));
			imgPass.Frame = new RectangleF (0, 0, 40, 28);
			ImgPassword.Layer.ZPosition = 1;
			ImgPassword.Add (imgPass);



		}
	}
}
